package net.qiqbframework.springboot.autoconfig;


import net.qiqbframework.domains.event.infra.persistence.DomainEventPersistence;
import net.qiqbframework.event.dao.mfimpl.*;
import net.qiqbframework.eventsourcing.dao.DomainEventDao;
import net.qiqbframework.eventsourcing.dao.DomainEventFeedbackDao;
import net.qiqbframework.eventsourcing.dao.DomainEventSubscriptionDao;
import net.qiqbframework.mf.MybatisFlexCondition;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;


@AutoConfiguration
@ConditionalOnClass(MybatisFlexCondition.class)
@ConditionalOnProperty(name = "qiqb.persisting.enable-mybatis-flex",havingValue = "true")
@MapperScan(basePackageClasses = {DomainEventMapper.class, DomainEventProcessMapper.class})
public class MybatisFlexModuleAutoConfiguration {

    @Bean
    public DomainEventPersistence qiqbDomainEventPersistenceMf(DomainEventDao domainEventDao, DomainEventSubscriptionDao domainEventSubscriptionDao, DomainEventFeedbackDao domainEventFeedbackDao) {
        return new DomainEventPersistence(domainEventDao, domainEventSubscriptionDao, domainEventFeedbackDao);
    }

    @Bean
    public DomainEventDao qiqbDomainEventDaoMfImpl() {
        return new DomainEventDaoMfImpl();
    }

    @Bean
    public DomainEventSubscriptionDao qiqbDomainEventSubscriptionDaoMfImpl() {
        return new DomainEventSubscriptionDaoMfImpl();
    }

    @Bean
    public DomainEventFeedbackDao qiqbDomainEventFeedbackDaoMfImpl() {
        return new DomainEventFeedbackDaoMfImpl();
    }

}
